using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class ScriptTimeoutPage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int runningTotal = 0;
         
        Server.ScriptTimeout=1;
         
        try
        {
            SqlConnection sqlConnection = 
            new SqlConnection("server=(local);database=northwind;"+
            "uid=sa;pwd=sa;");
            SqlCommand sqlCommand = new SqlCommand(
            "select * from Customers;"+
            "Select * from Suppliers;"+
            "Select * from Products;"+
            "select * from Orders;"+
            "select * from [Order Details]"+
            "select * from Customers;" +
            "Select * from Suppliers;" +
            "Select * from Products;" +
            "select * from Orders;" +
            "select * from [Order Details]"+
            "select * from Customers;"+
            "Select * from Suppliers;"+
            "Select * from Products;"+
            "select * from Orders;"+
            "select * from [Order Details]"+
            "select * from Customers;" +
            "Select * from Suppliers;" +
            "Select * from Products;" +
            "select * from Orders;" +
            "select * from [Order Details]",
             sqlConnection);
            sqlConnection.Open();
            SqlDataReader sqlDataReader=sqlCommand.ExecuteReader();
            Literal1.Text = "ScriptTimeout Property<br>";
            
            while (sqlDataReader.Read())
            {
                runningTotal++;
                Literal1.Text +="Customers <br>";
                for(int column =0; column<sqlDataReader.FieldCount;column++)
                {
                    Literal1.Text +=Convert.ToString(sqlDataReader[column]);
                    Literal1.Text += "-";
                }
                Literal1.Text += "<br>";
            }
            while (sqlDataReader.NextResult())
            {
                Literal1.Text += "Next Result <br>";
                while (sqlDataReader.Read())
                {
                    for (int column = 0; column < sqlDataReader.FieldCount; column++)
                    {
                        Literal1.Text += Convert.ToString(sqlDataReader[column]);
                        Literal1.Text += "-";
                    }
                    Literal1.Text += "<br>";
                }
                runningTotal++;
            }
            sqlDataReader.Close();
            sqlConnection.Close();
            sqlConnection.Dispose();
        }
        catch(Exception ex)
        {
            Response.Write(ex.Message);
        }
        Response.Write("runningTotal: " + runningTotal.ToString());
    }
}
